<?php
/*----------------------------------------------------------------------*
 * コンポーネント名 : 最新情報追加・編集画面初期表示ビュー
 * URL           : /new_infos/index
 * 最新バージョン   : v1.0
 * 作成日         : 2012/08/08
 * 担当者         : 野島賢三
 * 内容           : 新規作成
 *【改訂履歴】
 *----------------------------------------------------------------------*/
?>
<!-- INFOMAITION更新入力フォーム Start-->
<div id="newInfoInputBlock">
	<?php echo $this->form->create(array('default' => false));?>
	<?php echo $this->form->input('resistFor',
									array('type' => 'hidden',
											'id' => 'resistFor',
											'div' => false,
											'value' => 'NewInfo'));?>
	<?php echo $this->form->input('id',
									array('type' => 'hidden',
											'id' => 'in_id', 'div' => false));?>
	<h2>INFORMATION&nbsp;&nbsp;<span id='updType'>新規登録</span></h2>
	<table>
		<tbody>
			<tr>
				<th>公開日付&nbsp;&nbsp;<span id='errMessageDate' style="color: red;"></span></th>
			</tr>
			<tr>
				<td><?php echo $this->form->input('publish_ymd',
													array('label'=>'',
															'id'=>'in_publish_ymd',
															'timeFormat' =>'24',
															'dateFormat'=>'YMD',
															'monthNames'=>false));?>
				</td>
			</tr>
			<tr>
				<th>内&nbsp;容&nbsp;&nbsp;<span id='errMessageContent' style="color: red;"></span></th>
			</tr>
			<tr>
				<td><?php echo $this->form->input('content',
													array('type'=>'textarea',
															'label'=>'',
															'id'=>'in_content'
													));?>
				</td>
			</tr>
			<tr>
				<td>
					<div id="previewContent" style="display: none;">
						<h5>プレビュー</h5>
						<dl class="information" >
		            		<dt id="previewContentForPublishYmd">
		            			<span id="previewPublishY"></span><span id="previewPublishM"></span><span id="previewPublishD"></span>
		            		</dt>
		            		<dd style="background : none;">
		               			<div id="previewContentForContent" style="border-style:none;"></div>
		            		</dd>
	         			</dl>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<div id="publish_btns" style="display: none;">
						<?php echo $this->form->input('publish_flg',
														array('type'=>'radio',
																'label'=>false,
																'legend'=>false,
																'default'=>'0',
																'options'=>array('公開', '非公開')))?>
					</div>
				</td>
			</tr>
			<tr>
				<td><?php echo $this->form->button('クリア',
													 array('type'=>'reset',
													 		'id'=>'clearInfo'));?>
			 		<span id="previewBtn"><input type="button" id="reloadPreview" value="プレビュー" /></span>
					<span id='infoBtns' style="display: none;">
						<span id='resistInfoBtn'><?php echo $this->form->submit('登録する',
														array('id'=>'confirmAdd','div'=>false,
																'action'=>'add'));?></span>
						<span id='editNewInfoBtn' style="display:none;"><?php echo $this->form->submit('更新する',
													array('id'=>'confirmEdit','div'=>false,
															'action'=>'edit'));?></span>
					</span>
					<span id="previewCanBtn" style="display:none;"><input type="button" id="canPreview" value="やり直す" /></span>
				</td>
			</tr>
		</tbody>
	</table>
	<?php echo $this->form->end();?>
</div><!-- /#newInfoInputBlock -->
<!-- INFOMAITION更新入力フォーム End-->

<!-- INFOMAITION登録データ一覧 Start-->
<div id="dataListBlock">
<?php if (isset($new_info_datas)):?>
	<h2>INFORMATION&nbsp;一覧</h2>
	<!-- ページングボタン Start -->
	<div id='pagingBlock' style="height:20px;text-align:center;">
		<?php $this->Paginator->options(array('url' => array('#' =>'pagingBlock')));?>
		<div style="position: absolute;">
		<span id="prev" style="display:block;width:50px;float:left;position: absolute;left:30px;">
			<?php if ($this->Paginator->hasPrev()) echo $this->Paginator->prev('前へ');?>
		</span>
		<span id="page" style="display:block;width:50px;float:left;position: absolute;left:100px;">
			<?php echo $this->Paginator->numbers(array('separator'=> '/', 'modulus' => '2'));?>
		</span>
		<span id="next" style="display:block;width:60px;float:left;position: absolute;left:166px;">
			<?php if ($this->Paginator->hasNext()) echo $this->Paginator->next('次へ');?>
		</span>
		</div>
	</div><!-- /#pagingBlock -->
	<!-- ページングボタン End -->
	<?php echo $this->form->create(array('default' => false));?>
		<table id="infoUpdTable">
			<thead>
			<tr id="newInfoDateHeader">
				<th width="70px">日付</th>
				<th>内容<?php //if ($publish_flg) echo '&nbsp;&nbsp;&nbsp;※現在公開中';?></th>
				<th width="80px"></th>
			</tr>
			</thead>
			<tbody>
			<?php foreach ($new_info_datas as $new_info_data):?>
			<?php
				$publish_flg;
				$newInfoId = $new_info_data['NewInfo']['id'];
				if($new_info_data['NewInfo']['publish_flg'] == '0'){
					$publish_flg = TRUE;
				} else {
					$publish_flg=FALSE;
				}
			?>
			<tr id="infoId_<?=$newInfoId ?>">
				<td class="tdUpdDate" id="publish_ymd_<?=$newInfoId ?>"><?= $new_info_data['NewInfo']['publish_ymd']?></td>
				<td id="content_<?=$newInfoId ?>"><?= $new_info_data['NewInfo']['content']?></td>
				<td class="tdUpdBtn">
				<?php echo $this->form->input('編集',
											array('type' => 'button',
													'label' => false,
													'id' => 'edit_'.$newInfoId,
													'div' => false,
													'style' => 'font-size:10px'
													));?>
				<?php echo $this->form->input('削除',
											array('type'=>'button',
													'label'=>false,
													'id'=>'del_'.$newInfoId,
													'div'=>false,
													'style' => 'font-size:10px'
													));?>
				<?php
					if($publish_flg){
						echo $this->form->input('', array('type' => 'hidden',
														'id' => 'publishFlgChg_'.$newInfoId,
														'value' => '1'));
						echo $this->Html->image('now_publish.gif', array('border'=>'0'));
				 	} else {
				 		echo $this->form->input('', array('type' => 'hidden',
										 				'id' => 'publishFlgChg_'.$newInfoId,
										 				'value' => '0'));
						echo $this->Html->image('not_publish.gif', array('border'=>'0'));
				 	}
				 ?>
				</td>
			</tr>
			<?php endforeach;?>
			</tbody>
		</table>
	<?php echo $this->form->end();?>
<?php endif;?>
</div><!-- /#newInfoDataBlock -->
<!-- INFOMAITION登録データ一覧 End-->
<p id="dataList-top"><a href="#wrap">一覧へ</a></p>
